package auto;
import java.awt.BorderLayout;
import java.awt.Color;
	import java.awt.Dimension;
	import java.awt.GridBagConstraints;
	import java.awt.GridBagLayout;
	import java.awt.Insets;
import java.awt.Toolkit;
import java.awt.Dialog.ModalityType;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

	import javax.swing.ButtonGroup;
	import javax.swing.JButton;
	import javax.swing.JCheckBox;
import javax.swing.JDialog;
	import javax.swing.JFrame;
	import javax.swing.JLabel;
import javax.swing.JOptionPane;
	import javax.swing.JPanel;
	import javax.swing.JRadioButton;
	import javax.swing.JTextField;
import javax.swing.plaf.basic.BasicBorders.RadioButtonBorder;

public class AktivacijaPranje extends JDialog {
		
	

		
		/**
		 * 
		 */
		private static final long serialVersionUID = 1L;
		
		GridBagLayout grBagLayout = new GridBagLayout();
		GridBagConstraints grBagConstraints = new GridBagConstraints();
		
		private JPanel glavniPanel = null;
		private JPanel gornjiPanel = null;
		private JPanel donjiPanel = null;
		
		private JLabel regLabel = null;
		private JTextField regTextField = null;
		
		private JLabel cenaLabel = null;
		private JTextField cenaTextField = null;
		
		private JRadioButton radio1 = null;
		private JRadioButton radio2 = null;
		
		private ButtonGroup bg = new ButtonGroup();
		
		private JCheckBox check1 = null;
		private JCheckBox check2 = null;
		private JCheckBox check3 = null;
		private JCheckBox check4 = null;
		private JCheckBox check5 = null;
		
		private JButton okButton = null;
		private JButton cancelButton = null;
		
		private int fieldWidth = 150;
		Toolkit kit = Toolkit.getDefaultToolkit();
		Dimension dim = kit.getScreenSize();
		
		private CenterPanel cp;
		private int kojiButton;
		
		private int getKojiButton() {
			return kojiButton;
		}
		public void setKojiButton(int kojiButton) {
			this.kojiButton = kojiButton;
		}
		
		public AktivacijaPranje(int kojiButt, CenterPanel cpnl){
			this();
			cp = cpnl;
			kojiButton = kojiButt;
		}
		
		public AktivacijaPranje(int kojiButt){
			this();
			kojiButton = kojiButt;
		}
		
		public AktivacijaPranje(){
			pokreni();
			setLocation((dim.width-getWidth())/2, (dim.height-getHeight())/2);
			setResizable(false);
			setModalityType(ModalityType.APPLICATION_MODAL);
		}
		public void pokreni() {

			setTitle("Projekat");
			setContentPane(getGlavniPanel());
			pack();
		}
		private void initGBConst(int x, int y) {
			
			grBagConstraints.gridx = x;
			grBagConstraints.gridy = y;
			grBagConstraints.insets = new Insets(5, 5, 5, 5);
		}
		private JPanel getGlavniPanel() {
			if (glavniPanel == null) {
				glavniPanel = new JPanel();
				glavniPanel.setLayout(new BorderLayout());
				glavniPanel.add(getGornjiPanel(), BorderLayout.NORTH);
				glavniPanel.add(getDonjiPanel(), BorderLayout.SOUTH);

			}
			return glavniPanel;
		}
		public JPanel getGornjiPanel() {
			if (gornjiPanel == null) {
				gornjiPanel = new JPanel(grBagLayout);
				gornjiPanel.add(getRadio1());
				gornjiPanel.add(getRadio2());
				gornjiPanel.add(getRegLabel());
				gornjiPanel.add(getRegTextField());
				gornjiPanel.add(getCheck1());
				gornjiPanel.add(getCheck2());
				gornjiPanel.add(getCheck3());
				gornjiPanel.add(getCheck4());
				gornjiPanel.add(getCheck5());
				gornjiPanel.add(getCenaLabel());
				gornjiPanel.add(getCenaTextField());
			}
			return gornjiPanel;
		}
		public JPanel getDonjiPanel() {
			
			if (donjiPanel == null) {
				donjiPanel = new JPanel();
				donjiPanel.add(getOkButton());
				donjiPanel.add(getCancelButton());
			}
			return donjiPanel;
		}
		public JButton getOkButton() {
			if (okButton == null) {
				okButton = new JButton("OK");
				okButton.addActionListener(new ActionListener() {
					
					@Override
					public void actionPerformed(ActionEvent e) {
						cp.setBtn1Back(Color.RED);
						dispose();
					}
				});
				}
			return okButton;
		}
		public JButton getCancelButton() {
			if (cancelButton == null) {
				cancelButton = new JButton("Cancel");
				cancelButton.addActionListener(new ActionListener() {
					
					@Override
					public void actionPerformed(ActionEvent e) {
						
						dispose();
						
					}
				});
			}
				return cancelButton;
		}
		private JRadioButton getRadio1() {
			if (radio1 == null) {
				radio1 = new JRadioButton("1. Smena");
				radio1.setSelected(true);
				bg.add(radio1);
				initGBConst(0, 0);
				grBagLayout.setConstraints(radio1, grBagConstraints);
			}
			return radio1;
		}
		private JRadioButton getRadio2() {
				if (radio2 == null) {
					radio2 = new JRadioButton("2. Smena");
					radio2.setSelected(true);
					bg.add(radio2);
					initGBConst(1, 0);
					grBagLayout.setConstraints(radio2, grBagConstraints);
				}
				return radio2;
		}
		private JLabel getRegLabel() {
			if(regLabel == null){
			regLabel = new JLabel("Reg. br.");
			initGBConst(0, 1);
			grBagLayout.setConstraints(regLabel, grBagConstraints);
			}
			return regLabel;
		}
		public JTextField getRegTextField() {
			if (regTextField == null) {
				regTextField = new JTextField();
				regTextField.setPreferredSize(new Dimension(fieldWidth, 20));
				initGBConst(1, 1);
				grBagLayout.setConstraints(regTextField, grBagConstraints);
			}
			return regTextField;
		}
		
		public JCheckBox getCheck1() {
			if(check1 == null){
				check1 = new JCheckBox("Spolja");
				initGBConst(0, 2);
				grBagConstraints.anchor = GridBagConstraints.LINE_START;
				grBagLayout.setConstraints(check1, grBagConstraints);
				
			}
			return check1;
		}
		public JCheckBox getCheck2() {
			if(check2 == null){
				check2 = new JCheckBox("Iznutra");
				initGBConst(0, 3);
				grBagLayout.setConstraints(check2, grBagConstraints);
				
			}
			return check2;
		}
		public JCheckBox getCheck3() {
			if(check3 == null){
				check3 = new JCheckBox("Voskiranje");
				initGBConst(0, 4);
				grBagLayout.setConstraints(check3, grBagConstraints);
				
			}
			return check3;
		}
		public JCheckBox getCheck4() {
			if(check4 == null){
				check4 = new JCheckBox("Poliranje");
				initGBConst(0, 5);
				grBagLayout.setConstraints(check4, grBagConstraints);
				
			}
			return check4;
		}
		public JCheckBox getCheck5() {
			if(check5 == null){
				check5 = new JCheckBox("Dubinsko");
				initGBConst(0, 6);
				grBagLayout.setConstraints(check5, grBagConstraints);
				
			}
			return check5;
		}
		
		public JLabel getCenaLabel() {
			if(cenaLabel == null){
				cenaLabel = new JLabel("Cena :");
				initGBConst(0,7);
				grBagLayout.setConstraints(cenaLabel, grBagConstraints);
			}
			return cenaLabel;
		}
		public JTextField getCenaTextField() {
			if(cenaTextField == null){
				cenaTextField = new JTextField();
				cenaTextField.setPreferredSize(new Dimension(fieldWidth, 20));
				cenaTextField.setEditable(false);
				initGBConst(1,7);
				grBagLayout.setConstraints(cenaTextField, grBagConstraints);
			}
			return cenaTextField;
		}
		
		
		
			
		
		
		
		

	}

	
			

